const mongoose = require("mongoose");

const url = "mongodb://localhost/h51803"

mongoose.connect(url,{ useNewUrlParser: true });

//db理解为数据库,因为会返回数据库对象.
var db = mongoose.connection;

db.on("open",()=>{
    console.log("db is connected");
})

db.on('error', console.error.bind(console, 'connection error:'));

module.exports={
    db,
    mongoose
}